package model;


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;

import utility.HasColor;

public abstract class Element implements Alive, HasColor {

	protected Rectangle rectangle;
	
	protected boolean alive = true;
	protected boolean isBlocking;
	
	public Element(int x, int y, int width, int height, boolean isBlocking){
		this(new Rectangle(x, y, width, height), isBlocking);
	}
	public Element(Rectangle rect, boolean isBlocking){
		rectangle = rect;
		this.isBlocking = isBlocking;
	}
	
	public boolean isBlocking(){
		return isBlocking;
	}
	
	public abstract boolean blocks(Element e);
	
	public abstract boolean interactable();
	
	public abstract int depth();

	public Dimension getGridLocation(int gridWidth, int gridHeight){
		return getGridLocation(this.getX(),gridWidth, this.getY(),gridHeight);
	}
	public Dimension getGridLocation(int x, int y, int gridWidth, int gridHeight){
		return new Dimension(x/gridWidth, y/gridHeight);
	}
	
	public boolean isAlive(){
		return alive;
	}
	
	public void setAlive(boolean b){
		this.alive = b;
	}
	
	public int getWidth() {
		return rectangle.width;
	}

	public void setWidth(int width) {
		rectangle.width = width;
	}

	public int getHeight() {
		return rectangle.height;
	}

	public void setHeight(int height) {
		rectangle.height = height;
	}

	public int getY() {
		return rectangle.y;
	}

	public void setY(int y) {
		this.rectangle.y = y;
	}

	public int getX() {
		return rectangle.x;
	}

	public void setX(int x) {
		this.rectangle.x = x;
	}
	public Rectangle getRectangle(){
		return rectangle;
	}

	public Color getColor(){
		return Color.RED;
	}

	public void setRectangle(Rectangle rect) {
		this.rectangle = rect;
	}
	public void move(int x, int y) {
		rectangle.x+=x;
		rectangle.y+=y;
	}
}
